import pdfkit
# 假设这是一个本地HTML文件的路径，也可以是一个网页的网址
# pip install pdfkit
# pip install wkhtmltopdf
html_file_path = "https://www.web3d.org/specifications/X3Dv4/ISO-IEC19775-1v4-IS/Part01/components/core.html"
pdf_file_path = "example.pdf"
try:
    pdfkit.from_url(html_file_path, pdf_file_path)
    print("转换成功")
except Exception as e:
    print("转换失败:", e)